Integrate OpenAI Whisper API for Enhanced Transcription Support #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Title: Support Additional Whisper Services - Integration of OpenAI Whisper API
Background
This pull request addresses issue #137, which focuses on enhancing the flexibility and performance of our Telegram bot by supporting additional transcription services. The current implementation utilizes AWS Whisper for transcribing voice messages. With this update, we introduce support for the OpenAI Whisper API as an alternative transcription service.
Changes Implemented
Integration of OpenAI Whisper API
OpenAITranscriber
has been created to enable transcription using OpenAI's Whisper API. This class encapsulates the functionality necessary for interacting with the OpenAI service.Modification of Existing Classes
AudioTranscriber
class has been updated to accommodate both AWS and OpenAI transcription services. This change ensures that users have the flexibility to choose their preferred transcription backend.Configuration Changes
config.py
file has been modified to include:OPENAI_API_KEY
, which is required when using the OpenAI service.TRANSCRIPTION_SERVICE
, which defaults to 'aws'. Users can change this setting to 'openai' to utilize the OpenAI transcription service.Updates to Bot Handling
bot_handlers.py
file has been updated to initialize the correct transcription service based on the user's configuration. This change ensures the bot can dynamically select between AWS and OpenAI services seamlessly.Usage Guidelines
To switch between the AWS and OpenAI transcription services, users should set the following environment variables:
TRANSCRIPTION_SERVICE
: Set to 'aws' (default) or 'openai' depending on the desired transcription service.OPENAI_API_KEY
: Required when selecting the OpenAI service to enable successful transcription requests.Conclusion
This implementation maintains backward compatibility with the existing AWS service as the default option while offering enhanced flexibility through the addition of OpenAI's Whisper API. These changes aim to improve performance and cost-effectiveness to better meet user needs.
Please review the changes and let me know if further adjustments or enhancements are needed!